package com.camel.core.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;

/**
 * @author camel
 */
@Getter
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum  EntityStatus implements BaseEnum {
    /**/
    NORMAL(1, "正常"), UNVALID(0, "无效");

    @EnumValue
    private Integer code;
    private String desc;

    EntityStatus(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    @Override
    public Integer getValue() {
        return getCode();
    }

    public BaseEnum getEnumByValue(Integer value) {
        for (EntityStatus entityStatus : EntityStatus.values()) {
            if(entityStatus.getValue().equals(value)) {
                return entityStatus;
            }
        }
        return null;
    }
}
